<template>
  <UserCardList :user-list="userList" />
</template>

<script setup>

import {useRoute} from "vue-router";
import {onMounted, ref } from "vue";
import myAxios from "../plugins/myAxios.ts";
import {showFailToast, showSuccessToast} from "vant";
import qs from "qs";
import UserCardList from "../components/UserCardList.vue";

const route = useRoute();
const {tags} = route.query;

const userList = ref([]);

onMounted(async () => {
  const userListData = await myAxios.get('/user/recommend', {
    params: {
      pageSize: 1,
      pageNum: 20,
    },
    paramsSerializer: function (params) {
      return qs.stringify(params, { arrayFormat: "repeat" });
    },

  })
      .then(function (response) {
        console.log('/user/search/tags success', response)
        // userList = response.data
        showSuccessToast("请求成功")
        return response?.data?.records;
      })
      .catch(function (error) {
        console.log('/user/search/tags error', error)
        showFailToast("请求成功")
      });
  console.log(userListData, "数据列表")
  if (userListData) {
    userListData.forEach(user => {
      if (user.tags) {
        user.tags = JSON.parse(user.tags);
      }
    })
    userList.value = userListData
  }
})


</script>

<style scoped>

</style>